<template>
	<view class="shop-wrapper">
		<!-- <uni-nav-bar color="#333" @clickLeft="leftFun" :border="false" left-icon="left" backgroundColor="#fff"
			title="选择店铺"></uni-nav-bar> -->

		<view v-if='shopList.length > 0 '>
			<view class="shop-cell-box p30 bg-color-white mt20 pb20 "
			 v-for='(item,index) in shopList'
			 :key="index"
			:class="item.shopId == selectedShopId ? 'selected-shop-cell-box' : ''"
			@click="onChooseShop(item)"
			>
				<view class="flex_lr_m ">
					<view>
						<view class="f32 c333 mb20">
							{{ item.shopName }}
						</view>
						<view class="f28 c333">
							电话：{{ item.telephone }}
						</view>
						<view class="f28 c333 ell_more ell_2 ">
							地址：{{ item.address }}
						</view>
						<view class="f28 c333 ell_more ell_2 ">
							营业时间：{{ item.workTime }}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="flex_line_c no_msg_box" v-else>
			<image class="no_msg" src="../../static/images/no_data.png"></image>
			<view class="f28 c666">没有匹配的药店</view>
		</view>

	</view>

</template>

<script>
	import {
		qzApi
	} from '../../config/request';
	export default {
		data() {
			return {
				loactionForm: {
					latitude: 0,
					longitude: 0
				},
				shopList: [],
				selectedShopId: '',
				loadCompleted: false,
				requestForm: {
					pageNo: 1
				},
				prescId: '',
				orderId: ''
			}
		},
		methods: {
			async getShopListWithPrescriptionIdRequest(params) {
				uni.showLoading()

				const data = await qzApi.getShopListWithPrescriptionId(params);
				if (data && Array.isArray(data.data)) {
					this.shopList=data.data;
				}
			uni.hideLoading()
			},
			onChooseShop(e) {
			 console.log(e)
			 
			  var pages = getCurrentPages()
			  var prevPage = pages[pages.length - 2]
			  // prevPage.shopId= parseInt(e.shopId);
			  // prevPage.shopForm= e;
			  prevPage.$vm.getshop(e)
			  
			  uni.navigateBack({
			    delta: 1
			  })
			},

		},
		onLoad(options) {
			if (options.orderId) {
				// this.data.prescId = options.prescId
				this.orderId = options.orderId
				this.getShopListWithPrescriptionIdRequest(options.orderId)
			}
		}
	}
</script>

<style scoped>
	/* pages/shopList/shopList.wxss */

	page {
		background: #f7f7f7;
	}

	.shop-cell-box {
		border-radius: 20rpx;
		margin: 20rpx 20rpx;
	}

	.selected-shop-cell-box {
		border: 1px solid #F06454;
	}
</style>